home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / gs3.53 / gs_btokn.ps < prev    next >
Text File  |  1996-01-10  |  10KB  |  283 lines

  1. %    Copyright (C) 1994, 1995 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % Initialization file for binary tokens.
  16. % When this is run, systemdict is still writable,
  17. % but everything defined here goes into level2dict.
  18.  
  19. % Define whether or not to allow writing dictionaries.
  20. /WRITEDICTS true def
  21.  
  22. languagelevel 1 .setlanguagelevel
  23. level2dict begin
  24.  
  25. % Initialization for the system name table.
  26.  
  27. mark
  28. % 0
  29.     /abs /add /aload /anchorsearch /and
  30.     /arc /arcn /arct /arcto /array
  31.     /ashow /astore /awidthshow /begin /bind
  32.     /bitshift /ceiling /charpath /clear /cleartomark
  33. % 20
  34.     /clip /clippath /closepath /concat /concatmatrix
  35.     /copy /count /counttomark /currentcmykcolor /currentdash
  36.     /currentdict /currentfile /currentfont /currentgray /currentgstate
  37.     /currenthsbcolor /currentlinecap /currentlinejoin /currentlinewidth /currentmatrix
  38. % 40
  39.     /currentpoint /currentrgbcolor /currentshared /curveto /cvi
  40.     /cvlit /cvn /cvr /cvrs /cvs
  41.     /cvx /def /defineusername /dict /div
  42.     /dtransform /dup /end /eoclip /eofill
  43. % 60
  44.     /eoviewclip /eq /exch /exec /exit
  45.     /file /fill /findfont /flattenpath /floor
  46.     /flush /flushfile /for /forall /ge
  47.     /get /getinterval /grestore /gsave /gstate
  48. % 80
  49.     /gt /identmatrix /idiv /idtransform /if
  50.     /ifelse /image /imagemask /index /ineofill
  51.     /infill /initviewclip /inueofill /inufill /invertmatrix
  52.     /itransform /known /le /length /lineto
  53. % 100
  54.     /load /loop /lt /makefont /matrix
  55.     /maxlength /mod /moveto /mul /ne
  56.     /neg /newpath /not /null /or
  57.     /pathbbox /pathforall /pop /print /printobject
  58. % 120
  59.     /put /putinterval /rcurveto /read /readhexstring
  60.     /readline /readstring /rectclip /rectfill /rectstroke
  61.     /rectviewclip /repeat /restore /rlineto /rmoveto
  62.     /roll /rotate /round /save /scale
  63. % 140
  64.     /scalefont /search /selectfont /setbbox /setcachedevice
  65.     /setcachedevice2 /setcharwidth /setcmykcolor /setdash /setfont
  66.     /setgray /setgstate /sethsbcolor /setlinecap /setlinejoin
  67.     /setlinewidth /setmatrix /setrgbcolor /setshared /shareddict
  68. % 160
  69.     /show /showpage /stop /stopped /store
  70.     /string /stringwidth /stroke /strokepath /sub
  71.     /systemdict /token /transform /translate /truncate
  72.     /type /uappend /ucache /ueofill /ufill
  73. % 180
  74.     /undef /upath /userdict /ustroke /viewclip
  75.     /viewclippath /where /widthshow /write /writehexstring
  76.     /writeobject /writestring /wtranslation /xor /xshow
  77.     /xyshow /yshow /FontDirectory /SharedFontDirectory /Courier
  78. % 200
  79.     /Courier-Bold /Courier-BoldOblique /Courier-Oblique /Helvetica /Helvetica-Bold
  80.     /Helvetica-BoldOblique /Helvetica-Oblique /Symbol /Times-Bold /Times-BoldItalic
  81.     /Times-Italic /Times-Roman /execuserobject /currentcolor /currentcolorspace
  82.     /currentglobal /execform /filter /findresource /globaldict
  83. % 220
  84.     /makepattern /setcolor /setcolorspace /setglobal /setpagedevice
  85.     /setpattern
  86. % pad to 256
  87.     counttomark 256 exch sub { 0 } repeat
  88. % 256
  89.     /= /== /ISOLatin1Encoding /StandardEncoding
  90. % 260
  91.     /[ /] /atan /banddevice /bytesavailable
  92.     /cachestatus /closefile /colorimage /condition /copypage
  93.     /cos /countdictstack /countexecstack /cshow /currentblackgeneration
  94.     /currentcacheparams /currentcolorscreen /currentcolortransfer /currentcontext /currentflat
  95. % 280
  96.     /currenthalftone /currenthalftonephase /currentmiterlimit /currentobjectformat /currentpacking
  97.     /currentscreen /currentstrokeadjust /currenttransfer /currentundercolorremoval /defaultmatrix
  98.     /definefont /deletefile /detach /deviceinfo /dictstack
  99.     /echo /erasepage /errordict /execstack /executeonly
  100. % 300
  101.     /exp /false /filenameforall /fileposition /fork
  102.     /framedevice /grestoreall /handleerror /initclip /initgraphics
  103.     /initmatrix /instroke /inustroke /join /kshow
  104.     /ln /lock /log /mark /monitor
  105. % 320
  106.     /noaccess /notify /nulldevice /packedarray /quit
  107.     /rand /rcheck /readonly /realtime /renamefile
  108.     /renderbands /resetfile /reversepath /rootfont /rrand
  109.     /run /scheck /setblackgeneration /setcachelimit /setcacheparams
  110. % 340
  111.     /setcolorscreen /setcolortransfer /setfileposition /setflat /sethalftone
  112.     /sethalftonephase /setmiterlimit /setobjectformat /setpacking /setscreen
  113.     /setstrokeadjust /settransfer /setucacheparams /setundercolorremoval /sin
  114.     /sqrt /srand /stack /status /statusdict
  115. % 360
  116.     /true /ucachestatus /undefinefont /usertime /ustrokepath
  117.     /version /vmreclaim /vmstatus /wait /wcheck
  118.     /xcheck /yield /defineuserobject /undefineuserobject /UserObjects
  119.     /cleardictstack
  120. % 376
  121.     /A /B /C /D /E /F /G /H /I /J /K /L /M
  122.     /N /O /P /Q /R /S /T /U /V /W /X /Y /Z
  123.     /a /b /c /d /e /f /g /h /i /j /k /l /m
  124.     /n /o /p /q /r /s /t /u /v /w /x /y /z
  125. % 428
  126.     /setvmthreshold (<<) cvn
  127.     (>>) cvn /currentcolorrendering /currentdevparams /currentoverprint /currentpagedevice
  128.     /currentsystemparams /currentuserparams /defineresource /findencoding /gcheck
  129. % 440
  130.     /glyphshow /languagelevel /product /pstack /resourceforall
  131.     /resourcestatus /revision /serialnumber /setcolorrendering /setdevparams
  132.     /setoverprint /setsystemparams /setuserparams /startjob /undefineresource
  133.     /GlobalFontDirectory /ASCII85Decode /ASCII85Encode /ASCIIHexDecode /ASCIIHexEncode
  134. % 460
  135.     /CCITTFaxDecode /CCITTFaxEncode /DCTDecode /DCTEncode /LZWDecode
  136.     /LZWEncode /NullEncode /RunLengthDecode /RunLengthEncode /SubFileDecode
  137.     /CIEBasedA /CIEBasedABC /DeviceCMYK /DeviceGray /DeviceRGB
  138.     /Indexed /Pattern /Separation
  139. % 478 -- end
  140. .packtomark
  141.  
  142. % Install the system and user name tables.
  143. % The user name table is read-only for ordinary programs,
  144. % since it doesn't obey save/restore and must be managed specially.
  145.  
  146. dup /SystemNames exch def
  147. 100 array readonly dup /UserNames exch def
  148. .installnames
  149.  
  150. % Define printobject and writeobject.
  151. % These are mostly implemented in PostScript, so that we don't have to
  152. % worry about interrupts or callbacks when writing to the output file.
  153.  
  154. % Define procedures for accumulating the space required to represent
  155. % an object in binary form.
  156. /cntdict mark        % <#refs> <#chars> <obj> -proc- <#refs> <#chars>
  157.     /integertype /pop load
  158.     /realtype 1 index
  159.     /marktype 1 index
  160.     /nulltype 1 index
  161.     /booleantype 1 index
  162.     /nametype { length add } bind
  163.     /stringtype 1 index
  164.     /arraytype null
  165.     WRITEDICTS { /dicttype null } if
  166. .dicttomark def
  167. cntdict /arraytype
  168.  { dup dup length 5 -1 roll add 4 2 roll
  169.     { dup type //cntdict exch get exec } forall
  170.  } bind put
  171. WRITEDICTS
  172.  { cntdict /dicttype
  173.     { dup dup length 2 mul 5 -1 roll add 4 2 roll
  174.        { 4 1 roll dup type //cntdict exch get exec
  175.      3 -1 roll dup type //cntdict exch get exec
  176.        } forall
  177.     } bind put
  178.  } if
  179.  
  180. /w2dict mark
  181.     /nametype { 2 copy .writecvs pop } bind
  182.     /stringtype 1 index
  183. .dicttomark def
  184.  
  185. /.writeobjects        % <file> <tag> <array> .writeobjects -
  186.  {
  187.     mark exch
  188.  
  189.     % Count the space required for refs and strings.
  190.     dup length 0 3 -1 roll
  191.     % Stack: <file> <tag> -mark- <#refs> <#chars> <array>
  192.  
  193.     dup 4 1 roll
  194.      { dup type //cntdict exch get exec
  195.      } forall
  196.  
  197.     % Write the header.
  198.     % Stack: <file> <tag> -mark- <array1> ... <array|dictN> <#refs> <#chars>
  199.     counttomark 3 add -2 roll 4 1 roll
  200.     % Stack: -mark- <array1> ... <array|dictN> <tag> <#refs> <#chars> <file>
  201.     dup counttomark 1 sub index length
  202.     4 index 3 bitshift 4 index add
  203.     (xxxxxxxx) .bosheader writestring
  204.  
  205.     % Write the objects per se.
  206.     3 1 roll pop
  207.     counttomark 1 sub index length 3 bitshift exch
  208.     3 bitshift
  209.     % Stack: -mark- <array1> ... <array|dictN> <tag> <file> <ref#> <char#>
  210.  
  211.     counttomark 4 sub
  212.      { counttomark -1 roll dup 6 1 roll
  213.        dup type /dicttype eq        % can't be first object
  214.         {  { 5 1 roll (xxxxxxxx) .bosobject
  215.          3 index exch writestring
  216.          4 -1 roll (xxxxxxxx) .bosobject
  217.          3 index exch writestring
  218.            } forall
  219.         }
  220.         {  { (xxxxxxxx) .bosobject
  221.          dup 1 6 index put
  222.          3 index exch writestring
  223.          4 -1 roll pop 0 4 1 roll    % clear tag
  224.            } forall
  225.         }
  226.        ifelse
  227.      }
  228.     repeat
  229.  
  230.     % Write the strings and names.
  231.     pop pop exch pop
  232.     % Stack: -mark- <array1> ... <array|dictN> <file>
  233.  
  234.      counttomark 1 sub
  235.      { counttomark -1 roll
  236.         {        % The counting pass ensured that the keys and values
  237.             % of any dictionary must be writable objects.
  238.             % Hence, we are processing a dictionary iff
  239.             % the next-to-top stack element is not a file.
  240.           1 index type /filetype ne
  241.            { exch 2 index exch dup type //w2dict exch .knownget
  242.           { exec } { pop } ifelse pop
  243.            }
  244.           if
  245.               dup type //w2dict exch .knownget { exec } { pop } ifelse
  246.         } forall
  247.      }
  248.     repeat
  249.  
  250.     % Clean up.
  251.     % Stack: -mark- <file>
  252.  
  253.     pop pop
  254.  
  255.  } odef
  256. currentdict /cntdict undef
  257. currentdict /w2dict undef
  258.  
  259. /printobject { (%stdout) (w) file 3 1 roll writeobject } odef
  260. /writeobject { exch 1 array astore .writeobjects } odef
  261.  
  262. % Implement binary error message output.
  263.   /.printerror
  264.    { $error /binary get .languagelevel 2 eq and
  265.       { currentobjectformat 0 ne
  266.          { [ /Error $error /errorname get $error /command get false
  267.        ] 250 printobject
  268.      }
  269.      //.printerror
  270.     ifelse
  271.       }
  272.       //.printerror
  273.      ifelse
  274.    } bind def
  275.  
  276. % End of level2dict
  277.  
  278. end
  279. .setlanguagelevel
  280.